home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8876 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: fohnix.metronet.com!not-for-mail
  2. From: milam@fohnix.metronet.com (Stan Milam)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Convert String to Int?
  5. Date: 6 Mar 1996 15:31:11 -0600
  6. Organization: Texas Metronet, Inc  (login info (214/488-2590 - 817/571-0400))
  7. Message-ID: <4hl06v$rp8@fohnix.metronet.com>
  8. References: <4hf3sk$k57@hustle.rahul.net> <4hh5c9$iia@nadine.teleport.com>
  9. NNTP-Posting-Host: fohnix.metronet.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. GHouck (hksys@teleport.com) wrote:
  13. : Stephen Parry <sparry@rahul.net> wrote:
  14. : >I have some numbers, range 0 to 999, stored as a strings. I need to 
  15. : >convert them to integers. Could I get some hints how to do this?
  16. : >
  17. : >Stephen
  18. : Stephen,
  19. : One way is to use the function 'atoi()'; i.e.,  intVal = atoi( strVal );
  20. : Yours, Geoff Houck
  21.  
  22. You can also use strtol() and cast the result to whatever integer type
  23. you are working with.  I remember reading an article once, I think by
  24. P.J. Plauger, which stated strtol() was prefered over atoi() and atou(), and
  25. atol().
  26.  
  27. Regards,
  28. Stan Milam.
  29.